<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>定时器练习</title>
    <script>
        function show(){
            let i = 5;
            const timer = setInterval(function (){
                document.getElementById("title").innerText = i;
                if(i == 0){
                    console.log(timer)
                    clearInterval(timer)
                }
                i--;
            },1000)
        }
    </script>
</head>
<body>
    <h1 id="title">5</h1>
    <button onclick="show()">点击开始</button>
</body>
</html>